#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :获取组词.py
# @Time      :2024/11/12 
# @Author    :CL
# @email     :1037654919@qq.com


import requests

headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cache-Control": "no-cache",
    "Connection": "keep-alive",
    "Pragma": "no-cache",
    "Referer": "https://www.hanyuguoxue.com/zuci/",
    "Sec-Fetch-Dest": "document",
    "Sec-Fetch-Mode": "navigate",
    "Sec-Fetch-Site": "same-origin",
    "Sec-Fetch-User": "?1",
    "Upgrade-Insecure-Requests": "1",
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
    "sec-ch-ua": "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Linux\""
}
cookies = {
    "_ga": "GA1.1.1461385627.1729215826",
    "_ga_SRC3NVZE34": "GS1.1.1729231435.2.0.1729231435.0.0.0",
    "Hm_lvt_481e77a217efc98040c23f476554afef": "1729215565,1730268815,1731402483",
    "HMACCOUNT": "8A7B5B515FA69801",
    "Hm_lpvt_481e77a217efc98040c23f476554afef": "1731402545"
}
url = "https://www.hanyuguoxue.com/zuci/search"
params = {
    "words": "了"
}
response = requests.get(url, headers=headers, cookies=cookies, params=params)

# print(response.text)
print(response)
from bs4 import BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')
# print(soup.prettify())
data = soup.find_all('li', class_='text-center')
for item in data:
    print(item.text)

data = soup.find_all('div', class_='ci-list swiper-slide')
for item in data:
    # print(item.text)
    for li in item.find_all('li')[:10]:
        print(li.text)